/**
 * chinagoods.com
 * Copyright (c) 2020-2024 All Rights Reserved.
 */
package com.ruoyi.web.controller.common;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.ruoyi.common.exception.BusiException;

import java.util.Map;

/**
 * @author yangpeng
 * Created by on 2024-03-01 17:03
 */
public class CheckTimeUtil {
    public static void checkTime(Map<String, Object> params) {

        if (params == null || params.size() == 0) {
            throw new BusiException("请传入时间");
        }
        DateTime beginTime = DateUtil.parseDate(params.get("beginTime").toString());

        DateTime endTime = DateUtil.parseDate(params.get("endTime").toString());
        long day = DateUtil.betweenDay(beginTime, endTime, true);

        if (day >= 30) {
            throw new BusiException("时间区间不支持超过30天");
        }

    }
}